package components.dialogs
{
	import UIFree.controls.uif_baseCheckBox;
	import UIFree.controls.uif_checkbox;
	import UIFree.controls.uif_ebutton;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import flash.geom.Rectangle;
	
	public class clt_vipDialog extends clt_alertInvite {
		private static const _VIPBLOCKHEIGHT: int = 25;
		private var _vipHeight	: int;
		private var _services	: Array;
		private var _block		: uif_ecomponent;
		
		public function clt_vipDialog(parent:uif_component, message: String, servicesList: Array, closeFunc: Function) {
			_vipHeight = servicesList.length * _VIPBLOCKHEIGHT + 15;
			super(parent, message, function(): void {
				var cb: uif_checkbox = uif_baseCheckBox.getCheckedButton(_block);
				closeFunc(cb?cb._data:null);
			}, true);
			createServices(servicesList);
			show();
		}
		
		protected function createServices(a_list: Array, currency: String='мл.'): void {
			_services = new Array();
			var inner: Rectangle = getInner();
			inner.top = _desc.getOuter().bottom + 5;
			_block = new uif_ecomponent(this, inner.x, inner.y, inner.width, _vipHeight, 'description');
			var bi: Rectangle = _block.getInner();
			
			for (var i: int=0; i<a_list.length; i++) {
				var cb: uif_checkbox = new uif_checkbox(_block, bi.x, bi.y, bi.width, 22, 'chButton');
				cb.text = 'Купить ' + a_list[i].description + ' за ' + a_list[i].price + ' ' + currency;
				cb._data = a_list[i];
				bi.y += _VIPBLOCKHEIGHT;
			}
			cb.checked = true;
		}
		
		override protected function resizeFromText(): Rectangle {
			_desc.textField.height = _desc.textField.textHeight;
			_desc.height = _desc.textField.height + _desc.getSpace(true) * 2;
			height = _desc.height + getSpace(true) * 2 + 35 + _vipHeight; 
			return getInner();
		}
	}
}